<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %><!-- 数据库操作需要 -->  
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>用车申请表</title>
    <style>
        .main {
            width: 100%;
            height: 100%;
            background: RGB(239,239,239);
            float: left;
        }

        #header2 {
			height: 40px;
			background: #F6F6F6;
		}

        table,
        th,
        td {
            background-color: white;
            border: 1px solid black;
            border-collapse: collapse;
        }

        td {
            width: 200px;
            height: 25px;
            padding: 5px;
        }

        th {
            font-size: 16px;
        }

        .had {
            text-align: center;
            height: 600px;
            width: 80%;
            margin: 0px auto;
        }

        .input1 {
            border: none;
            height: 90%;
            width: 100%;
            font-size:16px;
            outline:none;
        }
        .input2 {
            color: black;
            background-color: RGB(239,239,239);
            font-size: 20px;
            height: 40px;
            width: 100px;
            margin-left:150px;
            margin-right:150px;
            
        }
        .input2:hover{
            background-color:#808080;
        }
        .text{
        	border: none;
            height: 50px;
            width: 100%;
            font-size:16px;
          	
        }

        select {
            border: 0px;
            height: 90%;
            width: 90%;
            outline:none;
        }

        textarea {
            border: 0px;
            
            width: 100%;
            resize: none;
            font-size: 16px;
        }

        .button1 {
            height: 40px;
            width: 120px;
            font-size: 15px;
            margin-left: 1000px;
            position:center;
            color: #000000;
            background-color: #808080;
        }

        h2 {
            text-align: center;
        }
        .button_file{
			background-color: white;
    		color:RGB(64,158,255);    		
    		height:22px;
   	 		text-align: center;
    		font-size: 16px;
    		border:none;
    		font-weight:bold;
		}
		.button_file:hover {
    		background-color:RGB(249,249,249);
		}
		.button_file:active {
 			 transform: translateY(2px);
		}
    </style>
</head>

<body>
<%	
	String ID=(String)session.getAttribute("ID");
	String RequestID=request.getParameter("RequestID");
	String Adminname=null;
	String Status=null;
	//第一个java代码段查询数据
	try{
		Class.forName("org.h2.Driver");//加载驱动
	} catch (ClassNotFoundException e) {
		e.printStackTrace();
		return;
	}
	String url="jdbc:h2:d:/CompanyCar/temp/mydbtest";
	Connection conn=null;

//数据库连接与查询过程中可能会引发sql异常
try {
	//获取数据库连接(url,username,password)			
	conn = DriverManager.getConnection(url,"sa","");
	//准备执行数据库查询	
	
	String sql1="select * from CarRequest where RequestID='"+RequestID+"'";
	String sql2="select Adminname from Admin where ID='"+ID+"'";
	String sql3="select Did from Driver";
	String sql4="select license_plate from car_info";
	//准备SQL执行;
	Statement stmt=conn.createStatement();
	//执行数据库查询，获取结果集
	ResultSet rs1=stmt.executeQuery(sql2);
	if (rs1.next()){
		Adminname=rs1.getString("Adminname");
	}
	ResultSet rs=stmt.executeQuery(sql1);
	if (rs.next()){
			//获取第1个字段
	}
	Status=rs.getString("Status");
%>
    <div class="main">
        <div id="header2">
            <img src="img/申请用车.png" alt="Big Boat" width="30" height="30" style=" vertical-align: middle;">
            车辆管理 > 派车单处理
        </div>
        <h2>用车申请表</h2>
        <form action="D-jdbc-addCheckList.jsp" method="post">
        <table class="had">
            
                <tr>
                    <th>乘车人数：</th>
                    <td><input class="input1" type="number" id="UsersNum" name="UsersNum" min="1" max="6" value=<%=rs.getString("UsersNum") %> readonly></td>
                    <th>用车范围：</th>
                    <td>
                        <input type="text" class="input1" value=<%=rs.getString("UseRange") %> readonly>
                    </td>
                    <th>联系电话：</th>
                    <td><input class="input1" type="text" id="Userphone" name="Userphone" value=<%=rs.getString("Userphone") %> readonly></td>
                </tr>
                <tr>
                    <th>用车时间：</th>
                    <td><input class="input1" type="datetime-local"  id="UseTime" name="UseTime" value=<%=rs.getString("UseTime") %> readonly></td>
                    <th>返回时间：</th>
                    <td><input class="input1" type="datetime-local"  id="ReturnTime" name="ReturnTime" value=<%=rs.getString("ReturnTime") %> readonly></td>
                    <th>紧急程度：</th>
                    <td>
                        <input type="text" class="input1" value=<%=rs.getString("degree") %> readonly>
                    </td>
                </tr>
                <tr>
                    <th>申请人工号：</th>
                    <td><input class="input1" type="text" id="EmpID" name="EmpID" value=<%=rs.getString("EmpID") %> readonly></td>
                    <th>申请时间：</th>
                    <td><input class="input1" type="text"  id="applyTime" name="applyTime" value=<%=rs.getString("applyTime") %> readonly></td>
                    <th>申请部门：</th>
                    <td>
                       
                        <input type="text" class="input1" value=<%=rs.getString("applyDepartment") %> readonly>
                    </td>
                </tr>
            
            
                <tr>
                    <th>起始地点</th>
                    <td colspan="2"><input class="input1" type="text" id="origin" name="origin" value=<%=rs.getString("origin") %> readonly></td>
                    <th>前往地点</th>
                    <td colspan="2"><input class="input1" type="text" id="goPlace" name="goPlace"value=<%=rs.getString("goPlace") %> readonly></td>
                </tr>
                <tr>
                    <th style="height:100px">用车事由</th>
                    <td colspan="5"><textarea id="UseReasons" name="UseReasons" rows="8" cols="30" style="outline:none;"readonly><%=rs.getString("UseReasons") %> </textarea></td>
                </tr>
            
            
                <tr >
                    <th >备注</th>
                    <td colspan="5" ><textarea id="Remarks" name="Remarks" rows="3" cols="30" style="outline:none;"readonly><%=rs.getString("Remarks") %> </textarea></td>
                </tr>
           		<tr>
                    <th style="height:50px">附件</th>
                    <td colspan="5" style="text-align:left">	
                    	<input type="button" class="button_file" value="添加附件" onclick="path.click()" >					
						<input type="text" class="text" name="lookfile" id="lookfile" style="outline:none;" value=<%=rs.getString("Attachment") %> readonly>											
						<input type="file"  id="Attachment" name="Attachment" style="display:none" onchange="lookfile.value+='   '+this.value">								
					</td>
                </tr> 
                <tr>
                	<th style="height:100px" rowspan="3">审核意见</th>
                	<td colspan="5" style="padding:0px;text-align:left;">
                        <input type="text" style="border:none; outline:none;" value=<%=rs.getString("AgreeOrNot") %> readonly>
                    </td>
                </tr>
                <tr>
                    <td colspan="5" ><textarea rows="3" cols="30" style="outline:none;" id="CensorContent" name="CensorContent" readonly><%=rs.getString("CensorContent") %></textarea></td>                 
                </tr>
                <tr>
                	<td colspan="5" style="text-align:right;">
                		<div style="float:right;width:100%">
                			审核人：<input type="text" id="Adminname" name="Adminname" style="border:none;outline:none;width:150px;height:20px;white-space: nowrap;color:RGB(153,153,153);" value=<%=rs.getString("Adminname")%> readonly>
                			审核时间：<input type="text" id="AdminTime" name="AdminTime" style="border:none;outline:none;width:150px;height:20px;color:RGB(153,153,153);" value=<%=rs.getString("AdminTime")%> readonly>
                		</div>
                	</td>
                </tr>
                <tr>
                	<th style="height:100px" rowspan="3">派车</th>
                	<th>车牌号</th>
                    <td colspan="2">
                    	<select class="input1" name="license_plate" >
                    		<option value="" style="display: none;" disabled selected>请选择车牌号</option>
                            	<%
			                		ResultSet rs4=stmt.executeQuery(sql4);
			                		while(rs4.next()){
			                	%>
			                		<option><%=rs4.getString("license_plate") %></option>
			                	<%
			                		}
			                	%>
                        </select>
                    
                   
					</td>
					<th>起始里程(KM)</th>
                    <td><input class="input1" type="number" id="km" name="km" step="0.1" required></td>
                </tr>
                <tr>
                	<th>驾驶员ID</th>
                    <td colspan="4">
                    	<select class="input1" name="Did" >
                    		<option value="" style="display: none;" disabled selected>请选择驾驶员</option>
                            	<%
			                		ResultSet rs3=stmt.executeQuery(sql3);
			                		while(rs3.next()){
			                	%>
			                		<option><%=rs3.getString("Did") %></option>
			                	<%
			                		}
			                	%>
                        </select>
					</td>
                </tr>
                <tr>
                	<td colspan="5" ><textarea name="instructions" rows="3" cols="30" style="outline:none;" placeholder="请输入派车情况说明" onclick="getphone()" required></textarea></td>
                </tr>
        </table>
        <br/>
        <input type="hidden" name="RequestID" value=<%=RequestID %>>
        <input type="button" onclick="Return()" class="input2" value="返回" style="white-space: nowrap;">
        <input type="submit" onclick="test()" class="input2" value="提交" style="white-space: nowrap;">
        <input type="reset" class="input2" value="清空">
        </form>
    </div>
<%
	//关闭表达式对象
	stmt.close();			
	//关闭数据库			
	conn.close();			
	
} catch (SQLException e) {
	e.printStackTrace();
} finally{
	//防止数据库未正常关闭
	try{
		if (conn!=null && (!conn.isClosed())){
			conn.close();
		}
	}catch(SQLException e){
		e.printStackTrace();
	}
}
%>    

<script type="text/javascript">
 function Return()
 {	

	 	window.location.href="D-car_manage.jsp";
 }

 </script>
</body>

</html>
